home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / djgpp / src / texinfo-.1 / info / dribble.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-29  |  2.3 KB  |  76 lines

  1. /* dribble.c -- Dribble files for Info. */
  2.  
  3. /* This file is part of GNU Info, a program for reading online documentation
  4.    stored in Info format.
  5.  
  6.    Copyright (C) 1993 Free Software Foundation, Inc.
  7.  
  8.    This program is free software; you can redistribute it and/or modify
  9.    it under the terms of the GNU General Public License as published by
  10.    the Free Software Foundation; either version 2, or (at your option)
  11.    any later version.
  12.  
  13.    This program is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    GNU General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with this program; if not, write to the Free Software
  20.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.    Written by Brian Fox (bfox@ai.mit.edu). */
  23.  
  24. #include <stdio.h>
  25. #include "dribble.h"
  26.  
  27. /* When non-zero, it is a stream to write all input characters to for the
  28.    duration of this info session. */
  29. FILE *info_dribble_file = (FILE *)NULL;
  30.  
  31. /* Open a dribble file named NAME, perhaps closing an already open one.
  32.    This sets the global variable INFO_DRIBBLE_FILE to the open stream. */
  33. void
  34. open_dribble_file (name)
  35.      char *name;
  36. {
  37.   /* Perhaps close existing dribble file. */
  38.   close_dribble_file ();
  39.  
  40. #if defined (__MSDOS__)
  41.   info_dribble_file = fopen (name, "wb");
  42. #else /* __MSDOS__ */
  43.   info_dribble_file = fopen (name, "w");
  44. #endif /* __MSDOS__ */
  45.  
  46. #if defined (HAVE_SETVBUF)
  47.   if (info_dribble_file)
  48. #  if defined (SETVBUF_REVERSED)
  49.     setvbuf (info_dribble_file, _IONBF, (char *)NULL, 1);
  50. #  else
  51.     setvbuf (info_dribble_file, (char *)NULL, _IONBF, 1);
  52. #  endif /* !SETVBUF_REVERSED */
  53. #endif /* HAVE_SETVBUF */
  54. }
  55.  
  56. /* If there is a dribble file already open, close it. */
  57. void
  58. close_dribble_file ()
  59. {
  60.   if (info_dribble_file)
  61.     {
  62.       fflush (info_dribble_file);
  63.       fclose (info_dribble_file);
  64.       info_dribble_file = (FILE *)NULL;
  65.     }
  66. }
  67.  
  68. /* Write some output to our existing dribble file. */
  69. void
  70. dribble (byte)
  71.      unsigned char byte;
  72. {
  73.   if (info_dribble_file)
  74.     fwrite (&byte, sizeof (unsigned char), 1, info_dribble_file);
  75. }
  76.